﻿
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace StoreWeb.ajax
{
    public partial class inventoryclass : System.Web.UI.Page
    {
        Maticsoft.BLL.InventoryClass dbll = new Maticsoft.BLL.InventoryClass();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request["action"]) && Request["action"] == "setprice")
                {
                    Maticsoft.Model.InventoryClass md = dbll.GetModel(Convert.ToInt32(Request["id"]));
                    md.price = Request["price"];
                    Response.Write(dbll.Update(md) ? 1 : 0);
                }
                else if (!string.IsNullOrEmpty(Request["action"]) && Request["action"] == "gettype")
                {
                    List<Maticsoft.Model.InventoryClass> list = dbll.GetModelList(string.Format("cinvCCode like '{0}%' and iinvcgrade = {1}", Request["cinvCCode"], Convert.ToInt32(Request["iinvcgrade"]) + 1));
                    Response.Write(JsonConvert.SerializeObject(list));
                }
                else
                {
                    Response.Write(string.Format("{0}", dbll.GetInventoryClassList(Request["id"], Request["ccodes"]) ? "1" : "0"));
                }
            }
        }
    }
}